<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>新增博客</title>
    <link rel="stylesheet" type="text/css" th:href="@{/css/admin/blog.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/h-ui/css/H-ui.min.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/h-ui.admin/css/H-ui.admin.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/h-ui.admin/css/style.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/lib/Hui-iconfont/1.0.8/iconfont.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/css/admin/admin.css}" />

</head>
<body>
<form id="editBlog">
    <input type="hidden" th:value="${result.get('article').id}" id="id"/>
    <input type="text" placeholder="输入文章标题" id="title" name="title" th:value="${result.get('article').title}" class="title"/>
    <span th:text="${result.get('article').content}" id="tet" style="display: none"></span>
    <div id="editor" class="edait" style="margin-top: 2%;margin-left: 2%">
    </div>

    <textarea id="text" class="text" style=""></textarea>
    <div class="row cl" style="margin-top: 2%;">
        <div>
            <dl class="permission-list" style="margin-left: 3.2%">
                <dt>
                    <label id="labels">选择标签</label>
                </dt>
                <dd>
                    <dl style="margin-left: -118px">
                        <dd>
                            <span th:each="aLabel : ${result.get('article').labels}"style="display: none">
                                <p id="te" name="te" th:text="${aLabel.id}"></p>
                            </span>
                            <label class="" th:each="lable : ${result.get('labels')}">
                                      <input type="checkbox" th:value="${lable.id}" name="label" id="user-Character-1-0-0">
                                      <span th:text="${lable.lableName}"></span>
                            </label>
                        </dd>
                    </dl>
                </dd>
            </dl>
            <dl class="permission-list" style="margin-left: 3.2%">
                <dt>
                    <label id="type">选择类型</label>
                </dt>
                <dd>
                    <dl style="margin-left: -118px">
                        <dd>
                            <p id="aType" name="te" th:text="${result.get('article').tid}" style="display: none"></p>
                            <label class="" th:each="type : ${result.get('types')}">
                                <input type="radio" th:value="${type.id}"  name="type" id="user-Character-2-0-0">
                                <span th:text="${type.typeName}"></span>
                            </label>
                        </dd>
                    </dl>
                </dd>
            </dl>
        </div>
    </div>
    <script type="text/javascript" th:src="@{/js/admin/addBlog.js}"></script>
    <div class="row cl" style="margin-top: 2%;margin-left: 70%">
        <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
            <button onClick="addBlog.saveBlog(1)" class="btn btn-primary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 保存并发布</button>
            <button onClick="addBlog.saveBlog(0)" class="btn btn-secondary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 保存草稿</button>
        </div>
    </div>
</form>
<script type="text/javascript" th:src="@{/js/jquery-2.0.3.min.js}"></script>
<script type="text/javascript" th:src="@{/layer/layer.js}"></script>
<script type="text/javascript" th:src="@{/WangEditor/wangEditor.min.js}"></script>
<script type="text/javascript" th:src="@{/js/admin/addBlog.js}"></script>

<script type="text/javascript">
    addBlog.init();
    /*多选框*/
    var ids= document.getElementsByName('te');
    var checkedValue = document.getElementsByName('label');
    for (i in ids){
        for (j in checkedValue){
            if (ids[i].innerText == checkedValue[j].value){
                checkedValue[j].checked=true;
            }
        }
    }
    /*单选框*/
    var tId = document.getElementById('aType').innerText;
    var radios = document.getElementsByName('type');
        for (radio in radios){
            if (tId == radios[radio].value){
                radios[radio].checked=true;
            }
    }
</script>
</body>
</html>
